<?php
namespace app\demo\controller\admin;

use app\BaseController;
use think\facade\View;

/**
 * 测试
 * Class Image
 * @package app\demo\controller\admin
 */
class Test extends BaseController
{
    public function test1(){
        return View::fetch('test1');
    }

    function curl_string ($url,$user_agent,$proxy){
        var_dump($url);
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_PROXY, $proxy);
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
        // curl_setopt ($ch, CURLOPT_COOKIEJAR, "d:\cookies.txt");
        curl_setopt ($ch, CURLOPT_HEADER, 1);
        curl_setopt ($ch, CURLOPT_HTTPHEADER, array('CLIENT-IP:125.210.188.36', 'X-FORWARDED-FOR:125.210.188.36'));  //此处可以改为任意假IP
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
        
        $result = curl_exec ($ch);
        curl_close($ch);
        var_dump($result);
        return $result;
    }

    public function testip1(){
        $url_page = "https://tan.cwjshop.cn/demo/admin.test/testip2";
        $user_agent = "Mozilla/4.0";
        $proxy = "http://125.119.175.48:8909";    //此处为代理服务器IP和PORT

        $string = $this->curl_string($url_page,$user_agent,$proxy);

        // var_dump($string);
    }

    public function testip2(){
        var_dump(request()->ip());
    }
}
